package com.douqu.game.core.database.model;

import com.bean.core.buffer.ByteBuffer;
import com.douqu.game.core.entity.ext.ArenaInfo;
import com.douqu.game.core.entity.ext.BagInfo;
import com.douqu.game.core.entity.ext.BattleInfo;
import com.douqu.game.core.entity.ext.InstanceInfo;
import com.douqu.game.core.entity.sprite.Player;

import java.util.Date;

public class PlayerModel {
    private Integer id;

    private String objectIndex;

    private String avatar;

    private Integer uid;

    private String name;

    private Integer camp;

    private Integer level;

    private Integer exp;

    private Integer grade;

    private Integer star;

    private Integer money;

    private Date createTime;

    private Boolean isDel;

    private Boolean online;

    private byte[] bagInfo;

    private byte[] battleInfo;

    private byte[] instanceInfo;

    private byte[] arenaInfo;


    public void copyFrom(Player player)
    {
        this.id = player.id;
        this.name = player.name;
        this.objectIndex = player.objectIndex;
        this.avatar = player.avatar;
        this.camp = player.camp;
        this.level = player.lv;
        this.exp = player.exp;
        this.uid = player.uid;
        this.grade = player.grade;
        this.star = player.star;
        this.money = player.money;
        this.isDel = player.isDel;
        this.online = false;

        //复制给PlayerModel
        ByteBuffer buffer = new ByteBuffer();
        player.getExtInfo(BagInfo.class).writeTo(buffer);
        this.bagInfo = buffer.getBytes();

        buffer = new ByteBuffer();
        player.getExtInfo(BattleInfo.class).writeTo(buffer);
        this.battleInfo = buffer.getBytes();

        buffer = new ByteBuffer();
        player.getExtInfo(InstanceInfo.class).writeTo(buffer);
        this.instanceInfo = buffer.getBytes();

        buffer = new ByteBuffer();
        player.getExtInfo(ArenaInfo.class).writeTo(buffer);
        this.arenaInfo = buffer.getBytes();
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCamp() {
        return camp;
    }

    public void setCamp(Integer camp) {
        this.camp = camp;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public Integer getExp() {
        return exp;
    }

    public void setExp(Integer exp) {
        this.exp = exp;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Boolean getIsDel() {
        return isDel;
    }

    public void setIsDel(Boolean isDel) {
        this.isDel = isDel;
    }

    public Boolean getOnline() {
        return online;
    }

    public void setOnline(Boolean online) {
        this.online = online;
    }

    public byte[] getBagInfo() {
        return bagInfo;
    }

    public void setBagInfo(byte[] bagInfo) {
        this.bagInfo = bagInfo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getObjectIndex() {
        return objectIndex;
    }

    public void setObjectIndex(String objectIndex) {
        this.objectIndex = objectIndex;
    }

    public Integer getGrade() {
        return grade;
    }

    public void setGrade(Integer grade) {
        this.grade = grade;
    }

    public Integer getStar() {
        return star;
    }

    public void setStar(Integer star) {
        this.star = star;
    }

    public Integer getMoney() {
        return money;
    }

    public void setMoney(Integer money) {
        this.money = money;
    }

    public byte[] getBattleInfo() {
        return battleInfo;
    }

    public void setBattleInfo(byte[] battleInfo) {
        this.battleInfo = battleInfo;
    }

    public byte[] getInstanceInfo() {
        return instanceInfo;
    }

    public void setInstanceInfo(byte[] instanceInfo) {
        this.instanceInfo = instanceInfo;
    }

    public byte[] getArenaInfo() {
        return arenaInfo;
    }

    public void setArenaInfo(byte[] arenaInfo) {
        this.arenaInfo = arenaInfo;
    }

    @Override
    public String toString() {
        return "PlayerModel{" +
                "id=" + id +
                ", objectIndex='" + objectIndex + '\'' +
                ", avatar='" + avatar + '\'' +
                ", uid=" + uid +
                ", name='" + name + '\'' +
                ", camp=" + camp +
                ", level=" + level +
                ", exp=" + exp +
                ", grade=" + grade +
                ", star=" + star +
                ", money=" + money +
                '}';
    }
}